package com.hdy.web.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hdy.web.pojo.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionMapper extends BaseMapper<Question> {
    @Select("select * from question_t;")
    List<Question> getAll()throws Exception;
    @Select("select * from question_t where postId=#{name};")
    List<Question> getByName(@Param("name") String name)throws Exception;
    @Insert("insert into question_t (postId,question,postDate)VALUES " +
            "(#{postId}, #{question}, now() ) ")
    @Options(useGeneratedKeys=true,keyProperty="entity.id",keyColumn = "id")
    int postQ(@Param("postId") String postId,
                  @Param("question") String question,@Param("entity") Question entity);
    @Delete("delete from question_t where id=#{qid}")
    int deleteQ(@Param("qid") int qid);
}
